package org.aspectsense.examples.adaptivemail;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

/**
 * 
 * Activate the <code>ExampleAdaptiveMail</code>
 * bundle. This is an End-User component. 
 * It is defined in an abstract level without providing
 * or requiring any service. Simply defines interfaces for
 * the required services and metadata needed for composing
 * and providing an AdaptiveMail application
 * 
 * @author Costas Kakousis
 * @author Nearchos Paspallis
 *
 */


public class ExampleAdaptiveMail implements BundleActivator {

	MailService mailServiceImpl = null;
	private ServiceRegistration serviceRegistration;

	public void start(BundleContext context) throws Exception {
	
		mailServiceImpl = new MailServiceImpl();
		assert serviceRegistration == null;
	
	    serviceRegistration = context.registerService(MailService.class.getName(), mailServiceImpl, null);
		
	}

	public void stop(BundleContext context) throws Exception {
		if(serviceRegistration != null)
	     {
			 serviceRegistration.unregister();
			 serviceRegistration = null;
	     }
	}

}
